﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;
using Wams.Admin;

namespace Wams.Server
{
    public class WamsVirtualPath
    {
        public string VirtualPath = null;
        public WamsContent Content = null;
    }

    public class WamsVirtualApp : WamsVirtualPath, IWamsApplication
    {
        public WamsServerSite ParentSite = null;

        public WamsVirtualApp(WamsServerSite parentSite)
        {
            ParentSite = parentSite;
        }

        public IsolationLevel AppPoolIsolation = IsolationLevel.Site;

        private string UniqueId = Guid.NewGuid().ToString();

        public string GetAppPoolName()
        {
            switch (AppPoolIsolation)
            {
                default: return ParentSite.GetAppPoolName();
                case IsolationLevel.VirtualApp: return string.Format("vApp_{0}", this.VirtualPath.Replace("/", "_").TrimStart('_'));
                case IsolationLevel.Full: return string.Format("vApp_{0}_{1}", this.VirtualPath.Replace("/", "_").TrimStart('_'), this.UniqueId);
            }
        }
    }
}